<template>
  <el-card :body-style="{ padding: '10px' }" shadow="hover" style="border: 0">
    <div slot="header">
      <span style="color: rgb(236,232,237)">员工风采</span>
      <el-button type="text" style="color: rgb(216,223,234)"
        class="staff-lookMoreBtn"
        @click="goview('员工风采')">
        查看更多...
      </el-button>
    </div>
    <div style="padding: 0 20px">
      <div id="de-card" class="cardBody">
        <template v-for="item in staffDemeanorList">
          <div class="staffHomeCard" :key="item.id"  @click="goViewWithQuery('查看风采',item.id)">
            <div class="briefText">
            <span style="margin-bottom: 1vh">
              {{item.content}}
            </span>
              <span style="color: #d3dce6; font-size: 0.75em">
              {{item.timestamp.slice(0,4)}}年{{item.timestamp.slice(5,7)}}月{{item.timestamp.slice(8,10)}}日
            </span>
            </div>
            <div class="miniPic">
              <el-image :src="baseUrl+'/'+item.src" fit="fill"></el-image>
            </div>
          </div>
        </template>
      </div>
    </div>
  </el-card>
</template>

<script>
import { baseURL } from '@/config/baseConfig'
import request from '@/network/request'
export default {
  name: 'staffDemeanor',
  data () {
    return {
      baseUrl: baseURL,
      staffDemeanorList: []
    }
  },
  created () {
    request({
      url: `/bulletin/showstaffmoment?pagenum=${1}&pagesize=${3}`
    }).then(res => {
      this.staffDemeanorList = res.data.data.data.result
      for (var i = 0, len = this.staffDemeanorList.length; i < len; i++) {
        if (this.staffDemeanorList[i].imgs.length !== 0) {
          this.staffDemeanorList[i].src = this.staffDemeanorList[i].imgs[0].imgurl
        } else {
          this.staffDemeanorList[i].src = ''
        }
      }
      // eslint-disable-next-line handle-callback-err
    }, error => {
      console.log('error')
    })
  },
  methods: {
    goview (name) {
      this.$router.push({ name }).catch(err => {
        err && console.log('刷新') // 待优化
      })
    },
    goViewWithQuery (name, data) {
      console.log('请求' + data + '通知')
      this.$router.push({ name, query: { data: data } }).catch(err => {
        err && console.log('刷新') // 待优化
      })
    }
  }
}
</script>

<style scoped>
.el-card{
  height: 100%;
  border: 0;
  border-radius: 0;
}
.el-card /deep/ .el-card__header {
  height: 10%;
  padding: 1vh 1vw;
  border-bottom: 0;
  box-sizing: border-box;
  background-color: #749376;
  color: white;
}
.staff-lookMoreBtn {
  float: right;
  padding: 0.2vh 0;
  color: white;
  font-size: 0.9em
}
.el-card /deep/ .el-card__body {
  height: 90%;
}
.cardBody{
  height: 100%;
  margin: 2vh auto;
}
.staffHomeCard {
  cursor:pointer;
  height: 22%;
  display: flex;
  border-bottom: #43454d 1px solid;
  padding-bottom: 1.5vh;
  margin-bottom: 1.5vh;
  justify-content: space-between;
  align-items:center;
}
.briefText {
  display: inline-block;
  margin-right: 0.6vw;
  width: 65%;
}
.briefText span{
  overflow: hidden;
  font-size: 0.8vw;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  color: #d9d9d9;
  -webkit-box-orient: vertical;
}
.el-image{
  height: 100%;
  width: 100%;
}
.el-image /deep/ img {
  margin: 0;
  width: 100%;
  height: 100%;
}
.miniPic{
  width: 30%;
  height: 8vh;
  background-color: yellow;
}
</style>
